//未被使用
<template>
    <div id="NewsNavBar">
      <van-nav-bar :left-text="showLeft?$t('theNews.prevPage'):''"
                   :left-arrow="showLeft"
                   @click-left="onClickLeft(comp_prevId)"
                   @click-right="onClickRight(comp_nextId)">
        <span v-if="showRight" slot="right" >{{$t('theNews.nextPage')}}<van-icon name="arrow" /></span>
      </van-nav-bar>

    </div>
</template>

<script>
  import {Toast} from 'vant';
  export default {
    name: "NewsNavBar",
    props: {
      prevId: Number,
      nextId: Number
    },
    computed:{
      comp_prevId:{
        get(){
          if(this.prevId===null){
            this.showLeft=false;
            return -1;
          }
          return this.prevId;
        },
        set(){}
      },
      comp_nextId:{
        get(){
          if(this.nextId===null){
            this.showRight=false;
            return -1;
          }
          return this.nextId;
        },
        set(){}
      }
    },
    data() {
      return{
        showLeft:true,
        showRight:true,
      }
    },
    methods: {
      onClickLeft(id) {
        if(id!==-1){
          this.getNewsDetails(id);
        }
      },
      onClickRight(id) {
        if(id!==-1){
          this.getNewsDetails(id);
        }
      },
      getNewsDetails(id) {
        let _this = this;
        this.axios.get(domain.url+'news/api/get_news_detail', {
          params: {
            id:id
          }
        })
          .then(function (response) {
            let data = response.data;
            //获取新闻详情
            _this.$emit('getNewNews',data)
          })
          .catch(function (error) {
            console.log(error);
          });
      },
    }
  }
</script>

<style scoped>
#NewsNavBar{
  padding:10px 10px 0 10px;
  font-size:12px;
}
#NewsNavBar .van-icon{
  color:#000;
}
.van-hairline--bottom::after{
  border-bottom: 0;
}
 .van-nav-bar__text {
    color:#000;
  }
</style>
